<?php 
require_once '../Lib/main.php';
$categoryDAO = new Dao_CategoryDAO();
$listCategory = $categoryDAO->getCategoryWithoutDelete();

$urlNew = getUrlAdmin("editproductclss.php",null);
?>
<script type="text/javascript">
Ext.onReady(function(){
	var storeTbl = Ext.create('Ext.data.Store', {
	    	fields: ['selected','id', 'name', 'orderIndex', 'folder','category_name', 'delStatus'],
	    	proxy: {
	            type: 'ajax',
	            url : 'get/listProductClass.php',
	            reader : {
	                type: 'json',
	                root: 'items',
	                totalProperty: 'total'
	            }
	        },
	        pageSize : 25,
	        listeners: {
		        load: function(store, records, successful, eOpts,respone) {
		           
		           var returnObj = store.getProxy().reader.rawData;
		           if (returnObj.success == false) {
						alert(returnObj.error);
						store.loadRecords([]);
		           }
		        }
		    }
		}
		
	);

	var gridPanel = Ext.create('Ext.grid.GridPanel', {
	    title: 'Danh sách nhóm sản phẩm (product_class)',
	    store: storeTbl,
	    viewConfig: {
	        markDirty: false
	    },
	    columns: [
	        {xtype: 'checkcolumn', text: '',  dataIndex: 'selected', width: 25},
			{ text: 'id',  dataIndex: 'id', width: '10%'},
	        { text: 'Tên',  dataIndex: 'name', width: '18%'},
	        { text: 'Tên Loại Sản phẩm',  dataIndex: 'category_name', width: '18%'},
	        { text: 'Thư mục hình',  dataIndex: 'folder', width: '20%'},
	        { text: 'Thứ tự Hiển thị', dataIndex: 'orderIndex', width: '10%'},
	        { text: 'Trạng thái', dataIndex: 'delStatus', width: '14%'},
	        { xtype: 'actioncolumn',align : 'center',width: 25,
		        items: [
				{
					icon: 'images/edit.png',
					handler: function (grid, rowIndex, colIndex) {
						    var record = grid.store.getAt(rowIndex);
							var id = record.get('id');
			        		location.href = '<?php echo $urlNew?>&id='+id;
						}
					}
				]
			}
	    ],
	   // height: '100%',
	    height : 400,
	    width: '100%',
	    renderTo: "tablePlace",
	    dockedItems: [{
	        xtype: 'pagingtoolbar',
	        store: storeTbl,   // same store GridPanel is using
	        dock: 'bottom',
	        displayInfo: true
	    }],
	    listeners : {
	        itemdblclick: function(dv, record, item, index, e) {
	        	var id = record.get('id');
	        	location.href = '<?php echo $urlNew?>&id='+id;
	        }
	    }
	});

	//gridPanel.headerCt.gridDataColumns[0].setVisible(true);
	//gridPanel.getSelectionModel().uncheckHeader();

	storeTbl.load();

	
	
	
	/*var name = $('#name').val();
	var orderIndex = $('#orderIndex').val();
	var delFlg = $('#deleteFLg').val();

	var txtNameCate = Ext.getCmp("txtNameCate");
	var txtOrderIndex = Ext.getCmp("txtOrderIndex");
	var cmbStausCate = Ext.getCmp("cmbStausCate");

	txtNameCate.setValue(name);
	txtOrderIndex.setValue(orderIndex);
	cmbStausCate.setValue(delFlg);*/
});

</script>

<a href="<?php echo $urlNew; ?>">Tạo mới</a> - <a href="#">Xóa</a>
<span id="tablePlace"></span>
		

		